var user = require('./utils/user.js');

//app.js
App({
  onLaunch: function () {
    const updateManager = wx.getUpdateManager();
    wx.getUpdateManager().onUpdateReady(function() {
      wx.showModal({
        title: '更新提示',
        content: '新版本已经准备好，是否重启应用？',
        success: function(res) {
          if (res.confirm) {
            // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
            updateManager.applyUpdate()
          }
        }
      })
    });
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    this.globalData.userInfo = null;
    this.globalData.hasLogin = false;
    this.globalData.role = '';
    this.globalData.userId = -1;
    this.globalData.myNurseId = -1;
    this.globalData.myName = '';
    this.globalData.mySex = '';
    this.globalData.myBirthday = '';
    this.globalData.metaId = -1;
    this.globalData.avatarUrl = '/static/common/image/default.png';
    this.globalData.status = false;
    this.globalData.nursePhone = "";

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  globalData: {
    userInfo: null,
    hasLogin: false,
    role: '',
    userId: -1,
    myNurseId: -1,
    myName:'',
    mySex:'',
    myBirthday:'',
    metaId: -1,
    avatarUrl: '/static/common/image/default.png',
    status: false,
    nursePhone:""
  }
})